﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
    <title>表单-管理员添加用户</title>
    <link rel="icon" href="favicon.ico" type="image/ico">


    <meta name="author" content="yinqi">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
</head>

<body data-logobg="color_8" data-sidebarbg="color_8">
<div class="layout-web">
    <div class="layout-container">

        <%--导航栏--%>
        <c:import url="nav.jsp"></c:import>

        <!--页面主要内容-->
        <main class="layout-content">

            <div class="container-fluid">

                <div class="col-md-12">
                    <div class="card">
                        <div class="card-header"><h4>基本样式</h4></div>
                        <div class="card-body">
                            <form id="form1" class="form-horizontal" action="empregist.action" method="post">
                                <div class="form-group">
                                    <label class="col-xs-12" for="name">用户名</label>
                                    <div class="col-xs-12">
                                        <input class="form-control" onblur="CheakName(this)" type="text" id="name"
                                               name="name" placeholder="文本..">
                                        <div class="help-block" style="color: red" id="mess"></div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-12" for="pass">密码</label>
                                    <div class="col-xs-12">
                                        <input class="form-control" type="password" id="pass" name="pass"
                                               placeholder="密码..">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-12" for="repass">确认密码</label>
                                    <div class="col-xs-12">
                                        <input class="form-control" type="password" id="repass" name="repass"
                                               placeholder="密码..">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-12" for="age">年龄</label>
                                    <div class="col-xs-12">
                                        <input class="form-control" type="number" id="age" name="age"
                                               placeholder="年龄..">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-12">性别</label>
                                    <div class="col-xs-12">
                                        <input type="radio" name="sex" value="男" checked="checked">男&nbsp;&nbsp;<input
                                            type="radio" name="sex" value="女">女
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-12" for="tel">电话</label>
                                    <div class="col-xs-12">
                                        <input class="form-control" type="text" id="tel" name="tel" placeholder="电话.."/>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-xs-12" for="email">邮箱</label>
                                    <div class="col-xs-12">
                                        <input class="form-control" type="tel" id="email" name="email"
                                               placeholder="邮箱..">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-xs-12">
                                        <button class="btn btn-primary" type="button" onclick="myfun1()">提交</button>
                                        <button class="btn btn-info" type="reset">重置</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>

            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
<script>
    function CheakName(obj) {
        var n = obj.value;
        console.log(n);
        $.post("empcheak.action", {name: n}, function (date) {
            console.log(date)
            if (date == "false") {
                console.log(2)
                $("#mess").html("用户已经存在");
            } else {
                console.log(3)
                $("#mess").html("")
            }
        });
    }


    function myfun1() {
        var name = $("#name").val();
        var pass = $("#pass").val();
        var repass = $("#repass").val();
        var tel = $("#tel").val();
        var email = $("#email").val();

        if (name == "") {
            alert("姓名不能为空");
            return;
        }
        if (pass == "") {
            alert("密码不能为空");
            return;
        }
        if (tel == "") {
            alert("电话号不能为空");
            return;
        }
        if (email == "") {
            alert("邮箱不能为空");
            return;
        }
        if (repass != pass) {
            alert("两次密码输入不一样，请重新输入");
            return;
        }
        $("#form1").submit();
    }
</script>
</body>
</html>